home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / Goodies / For TheDebugger / TList_Redef < prev   
Encoding:
Text File  |  1995-11-08  |  2.5 KB  |  88 lines  |  [TEXT/MPS ]

  1. =TYPE,redef
  2.  
  3. { type redefs for MacApp 3.3 Final for use with ••• MPW or Metrowerks ••• }
  4.  
  5.  
  6. CstringPtr = ^Cstring;
  7. pClassDesc = ^ClassDesc;
  8. hClassDesc = ^pClassDesc;
  9. ProcHandle = ^ProcPtr;
  10. pLongInt = ^LongInt;
  11. pinteger = ^integer;
  12.  
  13. ClassDesc = Record  { MA 3.3 Final }
  14. {   0} fDefaultConstructo : ProcHandle;
  15. {   4} fNextClassDesc     : pClassDesc;
  16. {   8} fClassName         : CstringPtr;
  17. {  12} fClassSize         : HLongInt;
  18. {  16} fClassID           : INTEGER;
  19. {  18} fAncestors         : hClassDesc;
  20. {  22} fAncestorOffsets   : pLongInt;
  21. end;
  22.  
  23. { p__mptr = ^__mptr; ignore this as Metrowerks is different }
  24. pCArrayIterator = ^CArrayIterator;
  25.  
  26. {        NOTE the use of 'Handle | ARRAY[1..fSize] of Tobject'  }
  27. {     to redefine list types in MacApp 3.3 Final }
  28.  
  29. {        YOU can generalize this trick to Similar types such as : }
  30. {        TDynamicArray, TSortedDynamicArray, TCmdTable, TMenuIDList, }
  31. {        TSortedHandleList, THandleList, TEventList , ...     }
  32.  
  33. TList = Record        { MacApp 3.3 Final }
  34.  fClassID           : Word;
  35.  __vptr             : HLongint; { in MPW:  p__mptr }
  36.  fIteratorPtr       : pCArrayIterator;
  37. filler1:integer;
  38.  fSize              : integer;    { Dbgr can't handle long Upper bnds }
  39.  fElementSize       : INTEGER;
  40.  fElementSizeShift  : INTEGER;
  41.  fAllocIncr : LongInt;
  42.  fAllocatedSize     : LongInt;
  43.  fFreeRequested     : Byte;
  44.  fArraySpace        : Handle | ARRAY[1..fSize] of Tobject;
  45.  fEltClassDesc      : pClassDesc;
  46. END;
  47.  
  48. { put other type redefs here }
  49. =t,redef
  50. TEntriesList = TList;
  51. TEventList = TList;
  52.  
  53. =-    commented out section
  54.  
  55.     Target Chain Menu Item by Steve Sissak
  56.  
  57. =AddMenu
  58. 'Target Chain/4'
  59. ?ReDirect('Target Chain');
  60. ?n := gExtDbgr_Info.n_classes; { use this as an error check }
  61. ?le := (gExtDbgr_Info.pOrderedClass)^; { ptr to array }
  62. ?targ := TApplication(gApplication^).fTarget;
  63. writeln('Current Task = ',CurApName:String);
  64. writeln;
  65. WHILE ?targ <> 0 DO BEGIN
  66.    ?beh := TEventHandler(?targ).fBehavior;
  67.    WHILE ?beh <> 0 DO BEGIN
  68.    ?id := TObject(?beh).fClassID - 1;  { the class ID }
  69.    if ?id <= ?n then begin
  70.    write('  ');
  71.    write( ClassDesc((?le+4*?id)^).fClassName^:CString:-1);
  72.    write('_@',?beh:HLongint:8);
  73.    writeln;
  74.    end;
  75.    ?beh := TBehavior(?beh).fNextBehavior;  { next on chain }
  76.    END;
  77.    ?id := TObject(?targ).fClassID - 1; { the class ID }
  78.    if ?id <= ?n then begin
  79.    write( ClassDesc((?le+4*?id)^).fClassName^:CString:-1);
  80.    write('_@',?targ:HLongint:8);
  81.    writeln;
  82.    end;
  83.    ?targ := TEventHandler(?targ).fNextHandler; { next on chain }
  84. END;
  85. ?ReDirect;
  86.  
  87. =-   end of scripting example
  88.